import matplotlib.pyplot as plt;
import numpy as np;

N=5
x=np.linspace(-1,5,100)
B=np.zeros((N,len(x)))
plt.figure()
for i in range(N):
    for j in range(len(x)):
        if x[j]>j-1 and x[j]<=i:
            B[i,j]=B[i,j]+(x[j]-i+1)**2/2
        elif x[j]>i and x[j]<=i+1:
            B[i,j]=B[i,j]+((x[j]-i+1)*(i+1-x[j])+(i+2-x[j])*(x[j]-i))/2
        elif x[j]>i+1 and x[j]<=i+2:
            B[i,j]=B[i,j]+(i+2-x[j])**2/2
    plt.plot(x,B[i,:])
plt.savefig("five_e.png")
